﻿
using chatGUI.Model;
using FreeSql.DataAnnotations;

namespace chatGUI.DataBase.Entity;

[Table(Name = "friends")]
public class FriendList{
    
    
    [Column(Name = "uid",IsPrimary = true)]
    public string Uid{ get; set; }
    [Column(Name = "fid",IsPrimary = true)]
    public string Fid{ get; set; }
    [Column(Name = "avatar_url")]
    public string AvatarUrl{ get; set; }
    [Column(Name = "nick_name")]
    public string NickName{ get; set; }
    
    [Column(Name = "remark_name")]
    public string RemarkName{ get;set;}
    

    public FriendList(){
    }
    public FriendList(messageData.User user)
    {
    }

    public static explicit operator friendListModel(FriendList friendList)
    {
        return new friendListModel
        {
            Id = friendList.Fid,
            FriendNickName = friendList.NickName,
            IsGroup = false,
            AvatarUrl = friendList.AvatarUrl
        };
    }
    public static explicit operator userDataModel(FriendList friendList)
    {
        return new userDataModel
        {
            Uid = friendList.Fid,
            NickName = friendList.NickName,
            RemarkName = friendList.NickName,
            AvatarUrl = friendList.AvatarUrl
        };
    }
    public override string ToString(){
        return $"{nameof(Uid)}: {Uid}, {nameof(Fid)}: {Fid}, {nameof(AvatarUrl)}: {AvatarUrl}, {nameof(NickName)}: {NickName}, {nameof(RemarkName)}: {RemarkName}";
    }
}